<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>成绩查询系统</title>
    <link rel="stylesheet" type="text/css" href="assets/admin/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="assets/admin/css/admin.css"/>
</head>
<body>
<div class="main-layout" id='main-layout'>
    <!--侧边栏-->
    <div class="main-layout-side">
        <div class="m-logo" style="color:white;line-height:60px;text-align:center; font-size:18px;">
            <span>成绩查询系统</span>
        </div>
        <ul class="layui-nav layui-nav-tree" lay-filter="leftNav">
            <li class="layui-nav-item">
                <a href="javascript:;" data-url="student-score.html"><i class="iconfont">&#xe602;</i>我的成绩</a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;" data-url="student-ScoreStatistics.html"><i class="iconfont">&#xe608;</i>成绩统计</a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;" data-url="student-update-password.html"><i class="iconfont">&#xe60a;</i>修改密码</a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;" data-id='6' data-url="loginOut" data-text="退出登录"><i
                        class="iconfont">&#x1006;</i>退出登录</a>
            </li>
        </ul>
    </div>
    <!--右侧内容-->
    <div class="main-layout-container">
        <!--头部-->
        <div class="main-layout-header">
            <div class="menu-btn" id="hideBtn">
                <!-- <a href="javascript:;">
                    <span class="iconfont">&#xe60e;</span>
                </a> -->
            </div>
            <ul class="layui-nav" lay-filter="rightNav">
                <!-- 					  <li class="layui-nav-item"><a href="javascript:;"  data-id='4' data-text="邮件系统"><i class="iconfont">&#xe603;</i></a></li>
                                      <li class="layui-nav-item">
                                        <a href="javascript:;" data-url="admin-info.html" style="color:black" data-id='5' data-text="个人信息">个人信息</a>
                                      </li>
                                       -->
                <li class="layui-nav-item"><a href="javascript:;" data-url="loginOut" style="color:black">欢迎您:<span
                        id="nowusername">xxxxx</span></a></li>
            </ul>
        </div>
        <!--主体内容-->
        <div class="main-layout-body">
            <!--tab 切换-->
            <div class="layui-tab layui-tab-brief main-layout-tab" lay-filter="tab" lay-allowClose="true">
                <ul class="layui-tab-title">
                    <li class="layui-this welcome">操作面板</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show" style="background: #f5f5f5;">
                        <!--1默认界面-->
                        <iframe src="student-score.html" id="iframInfo" width="100%" height="100%" name="iframe"
                                scrolling="auto" class="iframe" framborder="0"></iframe>
                        <!--1end-->
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--遮罩-->
    <div class="main-mask">

    </div>
</div>
<script src="assets/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
    $(".layui-nav-item a").on('click', function () {
        var address = $(this).attr("data-url");
        if (undefined == address || "undefined" == address) {
            alert("未配置地址");
        } else {
            if ("loginOut" == address) {
                loginOut();
            } else {
                $("#iframInfo").attr("src", address);
            }
        }
    })

    /* 	$("#loginOut").on('click',loginOut); */
    function loginOut() {

        layer.confirm('确定要退出？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/user/loginOut",//url
                data: {},
                success: function (result) {
                    if (result.code == "0") {
                        location.href = "/login.html";
                    } else {
                        alert(result.msg);
                    }
                },
                error: function () {
                    layer.msg('服务器错误', {
                        icon: 5
                    });
                }
            });
        }, function () {
            // layer.msg('第二个回调', {
            // 	time: 20000, // 20s 后自动关闭
            // 	btn: ['明白了', '知道了']
            // });
        });
    }
    $(function () {
        $.getJSON("/user/getnowuser", function (result) {
            if (result.code == "0") {
                var nowusername = result.data;
                $("#nowusername").text(nowusername);
            } else {
                layer.msg('请先登录', {icon: 5}, function () {
                    location.href="/login.html";
                });
            }
        }).fail(function() {  // 添加失败处理
            layer.msg('请先登录', {icon: 5}, function () {
                location.href="/login.html";
            });
        });
    });
</script>
<script src="assets/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/admin/js/common.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/admin/js/main.js" type="text/javascript" charset="utf-8"></script>

</body>
</html>
